使用docker配置dnsmasq

简介

配置

编辑 dnsmasq.conf

#dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf
#log all dns queries
log-queries
#dont use hosts nameservers
no-resolv
#Set a maximum TTL value for entries in the cache.
max-cache-ttl=60
#use google as default nameservers
server=8.8.4.4
server=8.8.8.8
#serve all .company queries using a specific nameserver
server=/company/10.0.0.1
#explicitly define host-ip mappings
address=/myhost.company/10.0.0.2

运行

docker run
–name dnsmasq
-d
-p 53:53/udp
-p 5380:8080
-v pwd/dnsmasq.conf:/etc/dnsmasq.conf
-e “USER=foo”
-e “PASS=bar”
jpillora/dnsmasq

测试

nslookup baidu.com 127.0.0.1
Server:		127.0.0.1
Address:	127.0.0.1#53

Non-authoritative answer:
Name:	baidu.com
Address: 123.125.114.144
Name:	baidu.com
Address: 111.13.101.208
Name:	baidu.com
Address: 220.181.57.217

成功返回百度的3个ip

还可以使用host 命令测试

host baidu.com 127.0.0.1
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases:

baidu.com has address 111.13.101.208
baidu.com has address 123.125.114.144
baidu.com has address 220.181.57.217
baidu.com mail is handled by 20 mx50.baidu.com.
baidu.com mail is handled by 10 mx.n.shifen.com.
baidu.com mail is handled by 20 mx1.baidu.com.
baidu.com mail is handled by 20 jpmx.baidu.com.

界面

这个docker 还提供一个简单的界面

访问 http://localhost:5380/ 可以访问到,并输入运行时指定的用户名密码

可以修改配置、重启程序等操作。

使用 github.com/jpillora/webproc

humboldt Written by:

humboldt 的趣味程序园